import Service from "../index";
import type { ModuleListVO } from "@pojo/ModuleListVO";
import type {
  CreateMenuBO,
  CreateModuleBO,
  GetAllMenuBo,
  UpdateMenuBO,
} from "./types";
import { MenuListVO } from "@/pojo/MenuListVO";

export default class SettingsService {
  static getModulesList() {
    return Service.getInstance().request<ModuleListVO[]>({
      url: "/admin/menu/module_list",
      method: "GET",
    });
  }

  static createModule(params: CreateModuleBO) {
    return Service.getInstance().request<void>({
      url: "/admin/menu/module_create",
      method: "POST",
      data: params,
    });
  }

  static createMenu(params: CreateMenuBO) {
    return Service.getInstance().request<void>({
      url: "/admin/menu/menu_create",
      method: "POST",
      data: params,
    });
  }

  static getAllMenu(params?: GetAllMenuBo) {
    return Service.getInstance().request<MenuListVO>({
      url: "/admin/menu/menu_list",
      method: "GET",
      params: params,
    });
  }

  static removeMenu(menuId: string | number) {
    return Service.getInstance().request<void>({
      url: "/admin/menu/menu_delete",
      method: "POST",
      data: {
        id: menuId,
      },
    });
  }

  static updateMenu(params: UpdateMenuBO) {
    return Service.getInstance().request<void>({
      url: "/admin/menu/menu_update",
      method: "POST",
      data: params,
    });
  }
}
